<?php
//*************************
// VER http://www.fpdf.org/
// HE MODIFICADO ESTE COMENTARIO
//*************************

//****************
// SECCION DE BBDD
//****************
$db = new mysqli('localhost', 'root', '', 'CO01-COCHES');
if ($db->connect_errno > 0) {
    die('Unable to connect to database [' . $db->connect_error . ']');
}
$sql = "SELECT * FROM CO01_MODELOS WHERE ID_MARCA=1";
$rows = $db->query($sql);
$db->close();

//**************
//SECCION DE PDF
//**************
require('/pdfcreator/fpdf.php');

$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial', '', 9);
$pdf->Cell(120,10,"MODELO");
$pdf->Cell(20,10,"C.E.");
$pdf->Ln();

while ($row = mysqli_fetch_array($rows)){

    if ($row["C_ENERGETICA"]=="A") {
        $pdf->SetTextColor(26, 132, 57);
    } else {
        $pdf->SetTextColor(160, 159, 146);
    }
    
    $pdf->Cell(120,4,$row["MODELO"],'L');
    $pdf->Cell(20,4,$row["C_ENERGETICA"],'LR');
    $pdf->Ln();
}
$pdf->Output();
?>
